//
//  CommonUntils.h
//  Project
//
//  Created by xfdc_003 on 2018/1/11.
//  Copyright © 2018年 xfdc. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface CommonUntils : NSObject


#pragma mark - 创建button

/**
 创建button
 
 @param frame button的frame
 @param title 标题
 @param fontOfSize 字体
 @param textAlignment 标显示方式
 @param titleColor 标题颜色
 @param backgroundColor 背景颜色
 @return 返回值
 */
+(UIButton *)createBtnFrame:(CGRect)frame
                      title:(NSString *)title
                 fontOfSize:(float)fontOfSize
              textAlignment:(NSTextAlignment)textAlignment
                 titleColor:(UIColor *)titleColor
            backgroundColor:(UIColor *)backgroundColor;



#pragma mark - 创建label

/**
 创建label
 
 @param frame label的frame
 @param text 标题
 @param textColor 标题颜色
 @param fontOfSize 标题字体
 @param textAlignment 标题显示方式
 @param numberOfLines 行数
 @param lineBreakMode 换行方式
 @return 返回值
 */
+(UILabel *)createLabelFrame:(CGRect)frame
                        text:(NSString *)text
                   textColor:(UIColor *)textColor
                  fontOfSize:(UIFont *)fontOfSize
               textAlignment:(NSTextAlignment)textAlignment
               numberOfLines:(NSInteger)numberOfLines
               lineBreakMode:(NSLineBreakMode)lineBreakMode;

#pragma mark - 创建VerticalLabel

/**
 创建VerticalLabel
 
 @param frame VerticalLabel的frame
 @param text 标题
 @param textColor 标题颜色
 @param fontOfSize 标题字体
 @param textAlignment 标题显示方式(水平)
 @param numberOfLines 行数
 @param lineBreakMode 换行方式
 @return 返回值
 */
+(TTTAttributedLabel *)createVerticalLabelFrame:(CGRect)frame
                                      text:(NSString *)text
                                 textColor:(UIColor *)textColor
                                fontOfSize:(UIFont *)fontOfSize
                             textAlignment:(NSTextAlignment)textAlignment
                             numberOfLines:(NSInteger)numberOfLines
                             lineBreakMode:(NSLineBreakMode)lineBreakMode;

#pragma mark - 创建textField

/**
 创建textField
 
 @param frame textField的frame
 @param placeholder 占位文字
 @param borderStyle 边框样式
 @param textColor 标题颜色
 @param fontOfSize 标题字体
 @param textAlignment 标题显示方式
 @return 返回值
 */
+(UITextField *)createTextFieldFrame:(CGRect )frame
                         placeholder:(NSString *)placeholder
                         borderStyle:(UITextBorderStyle)borderStyle
                           textColor:(UIColor *)textColor
                          fontOfSize:(float)fontOfSize
                       textAlignment:(NSTextAlignment)textAlignment;



//检测指定的字符串是否为正确的手机号码
+(BOOL)isMobilePhone:(NSString *)phoneNum;
//密码设置判断
+ (BOOL) validatePassword:(NSString *)passWord;
//身份证号判断
+ (BOOL)isValidCardNumber:(NSString *)value ;
//车牌号格式校验
+(BOOL)checkCarID:(NSString *)carID;


/// 计算高度
+(CGFloat)getHeightFromString:(NSString *)string WithFont:(UIFont *)font AndWidth:(CGFloat)width;
///计算加粗字体高度
+(CGFloat)getHeightFromString:(NSString *)string WithBoldFont:(CGFloat)boldfont AndWidth:(CGFloat)width;

/// 计算宽度
+(CGFloat)getWidthFromString:(NSString *)string WithFont:(CGFloat)font AndHeight:(CGFloat)height;

#pragma mark - 计算label文本高度
+(CGFloat)textHeight:(NSString*)text withFontSize:(CGFloat)fontSize withWidth:(CGFloat)width;

/// 改变同一个label里面字体大小颜色
+(NSMutableAttributedString *)changeLabelTextStyle:(NSString*)text  withChangeText:(NSString *)changeText withtextFont:(UIFont *)changeFont withtextColor:(UIColor *)changeColor;
/// 改变同一个label里面两部分字体大小颜色
+(NSMutableAttributedString *)changeLabelTextStyle:(NSString*)text  withChangeText:(NSString *)changeText withtextFont:(CGFloat)changeFont withtextColor:(UIColor *)changeColor withChangeTextTwo:(NSString *)changeTextTwo withtextTwoFont:(CGFloat)changeTwoFont withtextTwoColor:(UIColor *)changeTwoColor ;



+ (NSString *)currentDateStr;
+ (NSString *)currentTimeStr;
+ (NSString *)getDateStringWithTimeStr:(NSString *)str;
+ (NSString *)getTimeStrWithString:(NSString *)str;
//比较两个日期大小
+(int)compareDate:(NSString*)startDate withDate:(NSString*)endDate;
+(NSString *)dateFromNowDate:(NSString *)orderdate;
+(NSString *)dateFromOutDate:(NSString *)orderdate;

//图片转字符串
+(NSString *)UIImageToBase64Str:(UIImage *) image;
//字符串转图片
+(UIImage *)Base64StrToUIImage:(NSString *)_encodedImageStr;
+(NSString *)cutOutTime:(NSString *)time;
/**
 *  压缩图片到指定文件大小
 *
 *  @param image 目标图片
 *  @param size  目标大小（最大值）
 *
 *  @return 返回的图片文件
 */
+ (NSData *)compressOriginalImage:(UIImage *)image toMaxDataSizeKBytes:(CGFloat)size;


+ (void)setBorderWithView:(UIView *)view top:(BOOL)top left:(BOOL)left bottom:(BOOL)bottom right:(BOOL)right borderColor:(UIColor *)color borderWidth:(CGFloat)width;
+ (void)setBorderWithLabel:(UILabel *)label top:(BOOL)top left:(BOOL)left bottom:(BOOL)bottom right:(BOOL)right borderColor:(UIColor *)color borderWidth:(CGFloat)width;

+ (NSInteger)getDifferenceByDate:(NSString *)date ;

+ (BOOL)isBlankDictionary:(NSDictionary *)dic;

/*   参数介绍
 
 lineSpacing (行间距)
 
 FirstLineHeadIndent(首行缩进字符个数)
 
 FontOfSize (字号)
 
 TextColor(字体颜色)
 
 text(字符串内容)
 
 AddLabel(在哪个LB上面使用该特性)
 
 */
+(void)settingLabelTextAttributesWithLineSpacing:(CGFloat)lineSpacing FirstLineHeadIndent:(CGFloat)firstLineHeadIndent FontOfSize:(CGFloat)fontOfSize Font:(UIFont *)font TextColor:(UIColor *)textColor text:(NSString *)text AddLabel:(UILabel *)label;

//获取当前显示VC
+ (UIViewController *)getCurrentVC ;

+ (void)naviAddressWithDestination:(NSString *)destination  withLatitude:(NSString *)latitude withLongitude:(NSString *)longitude withController:(UIViewController *)vc;

@end
